<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
Zapatec Utils Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="zpdict.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>Zapatec Utils</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>zpdict.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		Zapatec Dictionary library. Used to translate various phrases
 from English to current language.

 <pre>
 Copyright (c) 2004-2009 by Zapatec, Inc.
 http://www.zapatec.com
 1700 MLK Way, Berkeley, California,
 94709, U.S.A.
 All rights reserved.
 </pre><BR/><BR/>
	
</p>

<hr>



<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**
 * <span class="attrib">@fileoverview</span> Zapatec Dictionary library. Used to translate various phrases
 * from English to current language.
 *
 * &lt;pre&gt;
 * Copyright (c) 2004-2009 by Zapatec, Inc.
 * http://www.zapatec.com
 * 1700 MLK Way, Berkeley, California,
 * 94709, U.S.A.
 * All rights reserved.
 * &lt;/pre&gt;
 */</span>

<span class="comment">// $Id: zpdict.js 15736 2009-02-06 15:29:25Z nikolai $</span>

<span class="reserved">if</span> (typeof zapatecDict != <span class="literal">'function'</span>) {

<span class="reserved">if</span> (typeof Zapatec == <span class="literal">'undefined'</span>) {
	<span class="comment">/**
	 * <span class="attrib">@ignore</span> Namespace definition.
	 */</span>
	Zapatec = <span class="reserved">function</span>() {};
}

<span class="comment">/**
 * <span class="attrib">@constructor</span>
 */</span>
zapatecDict =
Zapatec.Dict = <span class="reserved">function</span>() {};

<span class="comment">/**
 * Dictionary. Contains key-value pairs. Key is English phrase, value is phrase
 * in current language.
 * <span class="attrib">@private</span>
 */</span>
Zapatec.Dict.phrases = {};

<span class="comment">/**
 * Adds phrases to the dictionary.
 * Messages can be grouped like:
 * {
 *	firstGroup:{
 *		message1: "This is message 1 in first group",
 *		message2: "This is message 2 in first group"
 *	},
 *	secondGroup:{
 *		message1: "This is message 1 in second group",
 *		message2: "This is message 2 in second group"
 *	}
 * }
 * Messages can be accessed using zapatecTranslate("firstGroup.message1");
 * It will return "This is message 1 in first group"
 *
 * <span class="attrib">@param</span> {object} oDict Key-value pairs. Key is English phrase, value is phrase
 * in current language.
 */</span>
Zapatec.Dict.set = <span class="reserved">function</span>(oDict) {
	var aPhrases = zapatecDict.phrases;

	<span class="comment">// convert nested messages into dot-separated string</span>
	<span class="reserved">function</span> fFlatten(prefix, values){
		<span class="reserved">if</span>(typeof values == <span class="literal">"string"</span>){
			aPhrases[prefix] = values;
			<span class="reserved">return</span>;
		}

		<span class="reserved">if</span>(prefix != <span class="literal">""</span>){
			prefix += <span class="literal">"."</span>;
		}

		<span class="reserved">for</span> (var sKey in values) {
			fFlatten(prefix + sKey, values[sKey]);
		}
	}

	fFlatten(<span class="literal">""</span>, oDict);
};

<span class="comment">/**
 * Returns translation of English phrase. If there is no translation, returns
 * phrase itself.
 *
 * &lt;pre&gt;
 * This function overwrites {<span class="attrib">@link</span> Zapatec#translate}.
 * &lt;/pre&gt;
 *
 * <span class="attrib">@param</span> {string} sPhrase English phrase
 * <span class="attrib">@return</span> Translation into current language or undefined in case of invalid
 * arguments
 * <span class="attrib">@type</span> string
 */</span>
zapatecTranslate =
Zapatec.translate =
Zapatec.Dict.translate = <span class="reserved">function</span>(sPhrase) {
	<span class="comment">// Translate</span>
	var oPhrases = zapatecDict.phrases;

	<span class="reserved">if</span> (oPhrases[sPhrase]) {
		sPhrase = oPhrases[sPhrase];
	}

	<span class="comment">// make substitutions if more then one argument is passed.</span>
	<span class="comment">// replace %1, %2..., %N with corresponding argument</span>
	<span class="reserved">if</span>(arguments.length &gt; 1 &amp;&amp; typeof(sPhrase) == <span class="literal">"string"</span>){
		<span class="reserved">for</span>(var ii = 1; ii &lt; arguments.length; ii++){
			var re = new RegExp(<span class="literal">"(^|([^\\\\]))\%"</span>+ii);

			sPhrase = sPhrase.replace(re, <span class="literal">"$2"</span> + arguments[ii]);
		}
	}
	
	<span class="reserved">return</span> sPhrase;
};

<span class="comment">/**
 * Translates an array. Calls {<span class="attrib">@link</span> Zapatec.Dict#translate} for each element of
 * the array.
 *
 * &lt;pre&gt;
 * This function overwrites {<span class="attrib">@link</span> Zapatec#translateArray}.
 * &lt;/pre&gt;
 *
 * <span class="attrib">@param</span> {object} aArray Array to translate
 * <span class="attrib">@return</span> Translated array
 * <span class="attrib">@type</span> object
 */</span>
zapatecTranslateArray =
Zapatec.translateArray =
Zapatec.Dict.translateArray = <span class="reserved">function</span>(aArray) {
	var iLen = aArray.length;
	<span class="reserved">for</span> (var iItem = 0; iItem &lt; iLen; iItem++) {
		<span class="comment">// Translate item</span>
		aArray[iItem] = zapatecTranslate(aArray[iItem]);
	}
	<span class="reserved">return</span> aArray;
};

}
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>Zapatec Utils</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu May 21 12:19:24 2009</div>
</body>
</html>
